#include "common/common.h"
#include "thread_pool.h"

#define THREAD_NUM 4
#define QUEUE_SIZE 50


int main(){
    task_queue tq;
    char buf[MAX_LINE];
    tq_init(&tq, QUEUE_SIZE);
    pthread_t tid[THREAD_NUM];
    for(int i = 0; i < THREAD_NUM; i++){
        pthread_create(&tid[i], NULL, do_work, &tq);
    }

    while(1){
        FILE* fp = fopen("thread_pool.c", "r");
        if(fp == NULL){
            perror("fopen");
            exit(1);
        }
        while(fgets(buf, MAX_LINE, fp) != NULL){
            tq_push(&tq, buf);
        }
        fclose(fp);
    }
    
    return 0;
}